package com.lzh.chatnote.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 业务异常
 */

@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException{

    private String errorMsg;

    private Integer errorCode;

    public BusinessException(){
        super();
    }

    public BusinessException(String errorMsg){
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BusinessException(Integer errorCode, String errorMsg){
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BusinessException(ErrorEnums errorEnums){
        super(errorEnums.getErrorMsg());
        this.errorCode = errorEnums.getErrorCode();
        this.errorMsg = errorEnums.getErrorMsg();
    }

    @Override
    public String getMessage() {
        return errorMsg;
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }

}
